< previous page page_124 next page >

Page 124
Variants take up a significant amount of memory compared to normal data types. In addition, they are very slow to retrieve and get values. Because these requirements can slow down your application, you should use normal data types instead of variants whenever possible. Table 6.5 shows you the different data types a variant can store.
Table 6.5 Variant Data Types.
Data TypeDescription
EmptyDeclared but not yet initialized.
NullSpecial data type used with database applications.
ObjectSpecial data type that will be covered in Chapters 1921.
IntegerNormal data type.
LongNormal data type.
SingleNormal data type.
DoubleNormal data type.
CurrencyNormal data type.
DateNormal data type. Date and/or Time variable.
StringNormal data type.
BooleanNormal data type.

As you can see from the table, all the normal data types are accounted for, plus two additional types. The first type, Empty, is a special type thats used to initialize the variant when its declared. Just like an Integer data type is initialized to 0 and a string to "", a Variant data type is initialized to Empty. The other type is Null. A Null is a special value thats returned from a column in a table when no data is stored in that column. Whenever you retrieve data from a table, you need to store that data in a variant first, test it for Null, and then convert it into the data type you want.
Lets look at some code to see how to use the Variant data type:
9f31265bb40b592b1929e18a47ab28e5.gif
Dim vntVariable As Variant

vntVariable = 10
...
...

 
< previous page page_124 next page >

If you like this book, buy it!